import { renwuleixin, zulei, guanliyuanjiao } from "@/api/index";

export default {
  namespaced: true,

  state: {
    leixing: [],
    zu: [],
    jiaose: [],
  },
  mutations: {
    updateTypes(state, val) {
      state.leixing = val;
    },
    nazu(state, val) {
      state.zu = val;
    },
    jiao(state, val) {
      state.jiaose = val;
    },
  },
  actions: {
    getleixing(context) {
      return new Promise((resolve, reject) => {
        renwuleixin()
          .then((res) => {
            console.log(res, "lei");
            context.commit("updateTypes", res.data);
            resolve();
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
    getzu(context) {
      return new Promise((resolve, reject) => {
        zulei()
          .then((res) => {
            console.log(res, "zu");
            context.commit("nazu", res.data);
            resolve();
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
    getjiaose(context) {
      return new Promise((resolve, reject) => {
        guanliyuanjiao()
          .then((res) => {
            console.log(res, "jiaose");
            context.commit("jiao", res.data);
            resolve();
          })
          .catch((error) => {
            reject(error);
          });
      });
    },
  },

  getters: {},
};
